Reverse string if it’s length is a multiple of 4¶
‘’.join(reversed(S))
Write a python function to reverse a string if it’s length is a multiple of 4.
def reverse_string(S):
if len(S) % 4 == 0:
return ''.join(reversed(S))
return S
# test
print(reverse_string('abcd')) # dcba
print(reverse_string('python')) # python